﻿



/*
    业务分类
*/

$(function () {
    $('#bizTypeGrid').datagrid({
        url: '/BaseData/LoadBizTypeList',
        fitColumns: true,
        idField: 'Id',
        pagination: true,
        pageNumber: 1,
        pageSize: 20,
        nowrap: false,
        toolbar: '#bizTypeToolbar',
        height: 540,
        singleSelect: true,
        columns: [[
                    { field: 'Name', title: '名称', width: 100, align: 'center' }
                    
        ]],
        onDblClickRow: function (rowIndex, rowData) {
            alert(rowData.ID);
        }
    });

    $("#addBizType").bind("click", funAddBizType);
    $("#editBizType").bind("click", funEditBizType);
    $("#delBizType").bind("click", funDelBizType);
});


function funAddBizType() {
    art.dialog({
        title: '业务类型',
        content: "<iframe scrolling='yes' frameborder='0' src='/BaseData/BizTypeView' style='width:100%;height:100%;'/>",
        lock: false,
        initFn: function () {

        }
    });
}

function funEditBizType() {
    var rows = $("#bizTypeGrid").datagrid("getChecked");
    if (!rows || rows.length == 0) {
        alert("请选择要操作的数据!");
        return;
    }
    if (rows.length > 1) {
        alert("只能对单挑数据进行操作!");
        return;
    }
    var bId = rows[0].ID;
    art.dialog({
        title: '业务类型',
        content: "<iframe scrolling='yes' frameborder='0' src='/BaseData/BizTypeView?bizTypeId="+bId+"' style='width:100%;height:100%;'/>",
        lock: false,
        initFn: function () {

        }
    });

};

function funDelBizType() {

    var rows = $("#bizTypeGrid").datagrid("getChecked");
    if (!rows || rows.length == 0) {
        alert("请选择要操作的数据!");
        return;
    }
    if (rows.length > 1) {
        alert("只能对单挑数据进行操作!");
        return;
    }
    var bId = rows[0].Id;

    art.dialog({
        title: '删除提示',
        content: "是否删除：" + rows[0].Name + " ?",
        lock: false,
        initFn: function () {

        },
        button: [{
            name: '确定',
            callback: function () {
                DelBizType(bId);
            }, 
        },
        { name: '取消', focus: true }]
    })
}

function DelBizType(ID) {
    $.ajax({
        url: "/BaseData/DeleteBizType",
        type: "POST",
        dataType: "json",
        data: { "bizTypeId": ID },
        success: function (req) {
            if (req.IsSuccess) {
                $("#bizTypeGrid").datagrid("reload");
            }
            else {
                alert("删除失败");
            }
        }
    });
}